package jwdt.xadmin.goods.service.impl;

import java.util.List;
import java.util.Map;

import jwdt.common.dao.BaseDao;
import jwdt.xadmin.goods.bean.TMeetingRoom;
import jwdt.xadmin.goods.service.MeetingRoomManageService;

import com.ezerg.db.Jdb;
import com.ezerg.db.ext.PageUtil;

public class MeetingRoomManageServiceImpl implements MeetingRoomManageService {
	
	private BaseDao<TMeetingRoom> baseDao;

	public void setBaseDao(BaseDao<TMeetingRoom> baseDao) {
		this.baseDao = baseDao;
	}
	
	@Override
	public PageUtil selectMeetingRoom(PageUtil pu)throws Exception{
		pu.doList(TMeetingRoom.class);
		return pu;
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectUsedMeetingRoom()throws Exception{
		String sql = "select roomid,name from t_meetingroom where zt = 1";
		List<Map<String,String>> list = Jdb.get().query(sql);
		return list;
	}
	
	@Override
	public TMeetingRoom selectMeetingRoom(int roomid)throws Exception{
		return baseDao.doLoadObj(TMeetingRoom.class, roomid);
	}
	
	@Override
	public String saveMeetingRoom(int roomid,TMeetingRoom obj)throws Exception{
		if(roomid==0){
			return baseDao.doAddObj(obj);
		}
		return baseDao.doUpdateObj(TMeetingRoom.class, roomid, obj);
	}
	
	@Override
	public String delMeetingRoom(int roomid)throws Exception{
		return baseDao.doDelObj(TMeetingRoom.class, roomid);
	}
	
}
